<?php
/**
 * @uses       Custom_Controller_Action
 * @license    trafficgeyser.com
 */

class Custom_Controller_Action extends Zend_Controller_Action
{
	/**
	 * Flash Messenger object, will be used in controller
	 * @var object
	 */
	protected $_flash = '';

	/**
	 * Contains site full url
	 * @var string
	 */
	protected $_site_url = '';

	/**
	 * Check whether the request is ajax
	 * @var bool
	 */
	protected $isAjax = false;

	/**
	 * Check whether current user is admin or not
	 * @var bool
	 */
	protected $isAdmin = false;

	/**
	 * Set search key if search is posted
	 * @var string
	 */
	protected $searchKey = '';

	/**
	 * Auth object
	 * @var object
	 */
	protected $auth = '';

	/**
	 * Config container
	 * @var object
	 */
	protected $Config = '';

	/**
	 * Logger object
	 * @var object
	 */
	protected $_logger = '';

	function preDispatch()
	{
		$this->_logger	= Zend_Registry::get('logger');
		$this->Config	= Zend_Registry::get('config');
		$this->_flash	= $this->_helper->getHelper('FlashMessenger');
		$this->_site_url = $this->getRequest()->getScheme()."://".$this->getRequest()->getHttpHost();
		$this->isAjax = ($this->getRequest()->isXmlHttpRequest())?true:false;;
		$auth = Zend_Auth::getInstance();
		$this->auth = $auth;
//		$this->isAdmin = ($auth->hasIdentity() && $auth->getIdentity()->role_id == User_Model_DbTable_Role::ADMIN_USER)?true:false;
//
//		//set search for listing
//		$this->setSearch();
//		$this->_setActiveMenu();
//
//		#set to all view level variable
//		$this->view->siteURL = $this->_site_url;
//		$this->view->aclAuth = new User_Plugin_Auth_AuthPlugin();
//		$this->view->isAdmin = $this->isAdmin;
//		$this->view->dateFormat = $this->Config->params->dateFormat;
//        $this->view->timeFormat = $this->Config->params->timeFormat;
//        $this->view->jdateFormat = $this->Config->params->jquery->dateFormat;
//        $this->view->jtimeFormat = $this->Config->params->jquery->timeFormat;
// 
	}

	/**
	 * Add message to FlashMessenger plugin
	 * @param string $message
	 * @param string $type  Message type success,error etc
	 */
	public function addMessage($message, $type = 'success')
	{
        $translator = Zend_Registry::get('translate');
        $this->_flash->addMessage(array($type=>$translator->_($message)));
	}



	protected function RedirectUrl($url, array $options = array())
	{
		$this->_helper->redirector->gotoUrl($url, $options);
	}

	protected function Redirector($action, $controller, $module, $params = array())
	{
		$this->_helper->redirector($action, $controller, $module, $params);
	}
}

?>
